/**
 * 
 */
package dk.itu.mobile;

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import dk.itu.mobile.client.TcpClient;
import dk.itu.mobile.server.TcpServer;
import dk.itu.mobile.vo.Task;
import dk.itu.mobile.vo.TaskList;
import dk.itu.mobile.vo.User;

/**
 * @author niebje
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		//start Server in thread
		Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.INFO, "Starting ServerThread");
		Thread serverThread = new Thread(new TcpServer(12345));
		serverThread.start();
		TcpClient client = new TcpClient(12345);
		//client.taskListOps("TASK", "GET", "id-1");
		User hector = new User("Hector", "HectorPass");
		//User jacob = new User("Jacob", "JacobPass");
		client.takListObjOps("USER", "POST", hector);
		hector.password = "HecPass1";
		client.takListObjOps("USER", "PUT", hector);
		//client.takListObjOps("USER", "POST", jacob);
		Task task = new Task();
		
		
	}
	
	private static void testXMLparser() {
		
		TaskList tasklist = new TaskList();
		tasklist.users.add(new User("Niels Bjerg", "password"));
		tasklist.users.add(new User("Peter Tolstrup", "password"));
		tasklist.tasks.add(new Task("test1", "id-1", new Date(), "a test task",tasklist.users));
		
		//prints the list
//		System.out.println("printing demo class: \r");
//		System.out.println(TaskListSerializer.marshall(tasklist));
//		System.out.println("\rend of demo class.");
//		
//		//load a list
//		String path ="C:\\Workspaces\\Eclipse\\ITU\\TaskManager_Niels\\src\\dk\\itu\\mobile\\resources\\task-manager-xml.xml";
//		TaskList tl = TaskListSerializer.load(path, TaskList.class); 
//		System.out.println("Print loaded list:\r");
//		System.out.println(TaskListSerializer.marshall(tl));
//		System.out.println("End of loaded class print\r");
//		
//		//save a list
//		System.out.println("Save list to desk:\r");
//		String path1 ="C:\\Workspaces\\Eclipse\\ITU\\TaskManager_Niels\\src\\dk\\itu\\mobile\\resources\\task-manager-xml-1.xml";
//		TaskListSerializer.save(tl, path1);
//		System.out.println("List saved!\r");
//		
//		//load the saved list from desk
//		TaskList t2 = TaskListSerializer.load(path1, TaskList.class);
//		System.out.println("Print loaded list, Just saved:\r");
//		System.out.println(TaskListSerializer.marshall(t2));
//		System.out.println("End of loaded class print\r");
	}

}
